\(\int \sin (x) (a \cos (x)+b \sin (x)) \, dx\) [3]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [A] (verification not implemented)
   Maxima [A] (verification not implemented)
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 12, antiderivative size = 25 \[ \int \sin (x) (a \cos (x)+b \sin (x)) \, dx=\frac {b x}{2}-\frac {1}{2} b \cos (x) \sin (x)+\frac {1}{2} a \sin ^2(x) \]

[Out]

1/2*b*x-1/2*b*cos(x)*sin(x)+1/2*a*sin(x)^2

Rubi [A] (verified)

Time = 0.04 (sec) , antiderivative size = 25, normalized size of antiderivative = 1.00, number of steps used = 6, number of rules used = 5, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.417, Rules used = {3168, 2644, 30, 2715, 8} \[ \int \sin (x) (a \cos (x)+b \sin (x)) \, dx=\frac {1}{2} a \sin ^2(x)+\frac {b x}{2}-\frac {1}{2} b \sin (x) \cos (x) \]

[In]

Int[Sin[x]*(a*Cos[x] + b*Sin[x]),x]

[Out]

(b*x)/2 - (b*Cos[x]*Sin[x])/2 + (a*Sin[x]^2)/2

Rule 8

Int[a_, x_Symbol] :> Simp[a*x, x] /; FreeQ[a, x]

Rule 30

Int[(x_)^(m_.), x_Symbol] :> Simp[x^(m + 1)/(m + 1), x] /; FreeQ[m, x] && NeQ[m, -1]

Rule 2644

Int[cos[(e_.) + (f_.)*(x_)]^(n_.)*((a_.)*sin[(e_.) + (f_.)*(x_)])^(m_.), x_Symbol] :> Dist[1/(a*f), Subst[Int[
x^m*(1 - x^2/a^2)^((n - 1)/2), x], x, a*Sin[e + f*x]], x] /; FreeQ[{a, e, f, m}, x] && IntegerQ[(n - 1)/2] &&
 !(IntegerQ[(m - 1)/2] && LtQ[0, m, n])

Rule 2715

Int[((b_.)*sin[(c_.) + (d_.)*(x_)])^(n_), x_Symbol] :> Simp[(-b)*Cos[c + d*x]*((b*Sin[c + d*x])^(n - 1)/(d*n))
, x] + Dist[b^2*((n - 1)/n), Int[(b*Sin[c + d*x])^(n - 2), x], x] /; FreeQ[{b, c, d}, x] && GtQ[n, 1] && Integ
erQ[2*n]

Rule 3168

Int[sin[(c_.) + (d_.)*(x_)]^(m_.)*(cos[(c_.) + (d_.)*(x_)]*(a_.) + (b_.)*sin[(c_.) + (d_.)*(x_)])^(n_.), x_Sym
bol] :> Int[ExpandTrig[sin[c + d*x]^m*(a*cos[c + d*x] + b*sin[c + d*x])^n, x], x] /; FreeQ[{a, b, c, d}, x] &&
 IntegerQ[m] && IGtQ[n, 0]

Rubi steps \begin{align*} \text {integral}& = \int \left (a \cos (x) \sin (x)+b \sin ^2(x)\right ) \, dx \\ & = a \int \cos (x) \sin (x) \, dx+b \int \sin ^2(x) \, dx \\ & = -\frac {1}{2} b \cos (x) \sin (x)+a \text {Subst}(\int x \, dx,x,\sin (x))+\frac {1}{2} b \int 1 \, dx \\ & = \frac {b x}{2}-\frac {1}{2} b \cos (x) \sin (x)+\frac {1}{2} a \sin ^2(x) \\ \end{align*}

Mathematica [A] (verified)

Time = 0.01 (sec) , antiderivative size = 25, normalized size of antiderivative = 1.00 \[ \int \sin (x) (a \cos (x)+b \sin (x)) \, dx=\frac {b x}{2}-\frac {1}{2} a \cos ^2(x)-\frac {1}{4} b \sin (2 x) \]

[In]

Integrate[Sin[x]*(a*Cos[x] + b*Sin[x]),x]

[Out]

(b*x)/2 - (a*Cos[x]^2)/2 - (b*Sin[2*x])/4

Maple [A] (verified)

Time = 0.18 (sec) , antiderivative size = 20, normalized size of antiderivative = 0.80

method result size
risch \(\frac {x b}{2}-\frac {a \cos \left (2 x \right )}{4}-\frac {b \sin \left (2 x \right )}{4}\) \(20\)
default \(b \left (-\frac {\cos \left (x \right ) \sin \left (x \right )}{2}+\frac {x}{2}\right )-\frac {\cos \left (x \right )^{2} a}{2}\) \(21\)
parts \(b \left (-\frac {\cos \left (x \right ) \sin \left (x \right )}{2}+\frac {x}{2}\right )+\frac {a \sin \left (x \right )^{2}}{2}\) \(21\)
parallelrisch \(\frac {x b}{2}+\frac {a}{4}-\frac {b \sin \left (2 x \right )}{4}-\frac {a \cos \left (2 x \right )}{4}\) \(23\)
meijerg \(\frac {a \sqrt {\pi }\, \left (\frac {1}{\sqrt {\pi }}-\frac {\cos \left (2 x \right )}{\sqrt {\pi }}\right )}{4}+\frac {b \sqrt {\pi }\, \left (\frac {2 x}{\sqrt {\pi }}-\frac {\sin \left (2 x \right )}{\sqrt {\pi }}\right )}{4}\) \(43\)
norman \(\frac {b \tan \left (\frac {x}{2}\right )^{3}+2 \tan \left (\frac {x}{2}\right )^{2} a +x b \tan \left (\frac {x}{2}\right )^{2}-b \tan \left (\frac {x}{2}\right )+\frac {x b}{2}+\frac {x b \tan \left (\frac {x}{2}\right )^{4}}{2}}{\left (1+\tan \left (\frac {x}{2}\right )^{2}\right )^{2}}\) \(60\)

[In]

int(sin(x)*(a*cos(x)+b*sin(x)),x,method=_RETURNVERBOSE)

[Out]

1/2*x*b-1/4*a*cos(2*x)-1/4*b*sin(2*x)

Fricas [A] (verification not implemented)

none

Time = 0.24 (sec) , antiderivative size = 19, normalized size of antiderivative = 0.76 \[ \int \sin (x) (a \cos (x)+b \sin (x)) \, dx=-\frac {1}{2} \, a \cos \left (x\right )^{2} - \frac {1}{2} \, b \cos \left (x\right ) \sin \left (x\right ) + \frac {1}{2} \, b x \]

[In]

integrate(sin(x)*(a*cos(x)+b*sin(x)),x, algorithm="fricas")

[Out]

-1/2*a*cos(x)^2 - 1/2*b*cos(x)*sin(x) + 1/2*b*x

Sympy [A] (verification not implemented)

Time = 0.08 (sec) , antiderivative size = 37, normalized size of antiderivative = 1.48 \[ \int \sin (x) (a \cos (x)+b \sin (x)) \, dx=\frac {a \sin ^{2}{\left (x \right )}}{2} + \frac {b x \sin ^{2}{\left (x \right )}}{2} + \frac {b x \cos ^{2}{\left (x \right )}}{2} - \frac {b \sin {\left (x \right )} \cos {\left (x \right )}}{2} \]

[In]

integrate(sin(x)*(a*cos(x)+b*sin(x)),x)

[Out]

a*sin(x)**2/2 + b*x*sin(x)**2/2 + b*x*cos(x)**2/2 - b*sin(x)*cos(x)/2

Maxima [A] (verification not implemented)

none

Time = 0.21 (sec) , antiderivative size = 21, normalized size of antiderivative = 0.84 \[ \int \sin (x) (a \cos (x)+b \sin (x)) \, dx=-\frac {1}{2} \, a \cos \left (x\right )^{2} + \frac {1}{4} \, b {\left (2 \, x - \sin \left (2 \, x\right )\right )} \]

[In]

integrate(sin(x)*(a*cos(x)+b*sin(x)),x, algorithm="maxima")

[Out]

-1/2*a*cos(x)^2 + 1/4*b*(2*x - sin(2*x))

Giac [A] (verification not implemented)

none

Time = 0.27 (sec) , antiderivative size = 19, normalized size of antiderivative = 0.76 \[ \int \sin (x) (a \cos (x)+b \sin (x)) \, dx=\frac {1}{2} \, b x - \frac {1}{4} \, a \cos \left (2 \, x\right ) - \frac {1}{4} \, b \sin \left (2 \, x\right ) \]

[In]

integrate(sin(x)*(a*cos(x)+b*sin(x)),x, algorithm="giac")

[Out]

1/2*b*x - 1/4*a*cos(2*x) - 1/4*b*sin(2*x)

Mupad [B] (verification not implemented)

Time = 21.22 (sec) , antiderivative size = 19, normalized size of antiderivative = 0.76 \[ \int \sin (x) (a \cos (x)+b \sin (x)) \, dx=\frac {a\,{\sin \left (x\right )}^2}{2}-\frac {b\,\cos \left (x\right )\,\sin \left (x\right )}{2}+\frac {b\,x}{2} \]

[In]

int(sin(x)*(a*cos(x) + b*sin(x)),x)

[Out]

(a*sin(x)^2)/2 + (b*x)/2 - (b*cos(x)*sin(x))/2